package com.example.projectcode.controller.Teacher;

import com.example.projectcode.result.Result;
import com.example.projectcode.service.TeacherService;
import com.example.projectcode.vo.TeacherVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "教师端信息管理")
@RestController
@RequestMapping("/teacher/persion")
public class TeacherManager {

    @Autowired
    private TeacherService teacherService;


    @ApiOperation("修改教师个人密码")
    @GetMapping(value = "/updatePassword/{teaId}/{teaPassword}")
    public Result updatePassword(@PathVariable Integer teaId, @PathVariable String teaPassword){
        int result  = teacherService.updatePasswordById(teaId,teaPassword);
        if (result>0){
            return Result.ok().message("修改密码成功");
        }else {
            return Result.ok().message("修改密码失败");
        }
    }

    @ApiOperation("修改教师个人信息")
    @PostMapping("/updatePersion")
    public Result updatePersion(@RequestBody TeacherVo teacherVo){
        int result = teacherService.updateTeacherByVo(teacherVo);
        if (result>0){
            return Result.ok().message("修改成功");
        }else {
            return Result.fail().message("修改失败");
        }
    }


}
